#region Using

using System;
using System.IO;
using System.Net.Mail;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using BlogEngine.Core;

#endregion

public partial class admin_slideshow_settings : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!IsPostBack)
			BindSettings();

		Page.MaintainScrollPositionOnPostBack = true;
		Page.Title = Resources.labels.settings;

		btnSave.Click += new EventHandler(btnSave_Click);

		btnSave.Text = Resources.labels.saveSettings;
	}

	private void btnSave_Click(object sender, EventArgs e)
	{		
		//-----------------------------------------------------------------------
		// Slideshow Settings
		//-----------------------------------------------------------------------
		BlogSettings.Instance.SlideShowWidth = int.Parse(txtSlideshowDefaultWidth.Text);
		BlogSettings.Instance.SlideShowHeight = int.Parse(txtSlideshowDefaultHeight.Text);
		BlogSettings.Instance.SlideShowEnableShuffleMode = cbSlideshowEnableShuffleMode.Checked;
		BlogSettings.Instance.SlideShowShowNavBar = cbSlideshowShowNavBar.Checked;
		BlogSettings.Instance.SlideShowShowLoadIcon = cbSlideshowShowLoadIcon.Checked;
		BlogSettings.Instance.SlideShowStretchImage = ddlSlideShowStretchImage.SelectedItem.Value;
		BlogSettings.Instance.SlideShowDuration = int.Parse(txtSlideshowDurationTime.Text);
		BlogSettings.Instance.SlideShowTransitionEffect = ddlSlideshowTransitionEffect.SelectedItem.Value;
		BlogSettings.Instance.SlideShowBackGroundColor = txtSlideshowBackgroundColor.Text;
		BlogSettings.Instance.SlideShowTextColor = txtSlideshowTextColor.Text;
		BlogSettings.Instance.SlideShowRolloverColor = txtSlideshowRolloverColor.Text;
		BlogSettings.Instance.SlideShowPhotoSize = int.Parse(txtPhotoSize.Text);

		//-----------------------------------------------------------------------
		//  Persist settings
		//-----------------------------------------------------------------------
		BlogSettings.Instance.Save();
		Response.Redirect(Request.RawUrl, true);
	}

	private void BindSettings()
	{		
		//-----------------------------------------------------------------------
		// Slideshow Settings
		//-----------------------------------------------------------------------
		txtSlideshowDefaultWidth.Text = BlogSettings.Instance.SlideShowWidth.ToString();
		txtSlideshowDefaultHeight.Text = BlogSettings.Instance.SlideShowHeight.ToString();
		cbSlideshowEnableShuffleMode.Checked = BlogSettings.Instance.SlideShowEnableShuffleMode;
		cbSlideshowShowNavBar.Checked = BlogSettings.Instance.SlideShowShowNavBar;
		cbSlideshowShowLoadIcon.Checked = BlogSettings.Instance.SlideShowShowLoadIcon;
		ddlSlideShowStretchImage.SelectedValue = BlogSettings.Instance.SlideShowStretchImage;
		txtSlideshowDurationTime.Text = BlogSettings.Instance.SlideShowDuration.ToString();
		ddlSlideshowTransitionEffect.SelectedValue = BlogSettings.Instance.SlideShowTransitionEffect;
		txtSlideshowBackgroundColor.Text = BlogSettings.Instance.SlideShowBackGroundColor;
		txtSlideshowTextColor.Text = BlogSettings.Instance.SlideShowTextColor;
		txtSlideshowRolloverColor.Text = BlogSettings.Instance.SlideShowRolloverColor;
		txtPhotoSize.Text = BlogSettings.Instance.SlideShowPhotoSize.ToString();
	}


}